/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tkgarment.system.dao;

import com.tkgarment.system.domain.History;
import com.tkgarment.system.factory.DAOFactory;
import com.tkgarment.system.inf.IDAO;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *
 * @author zraj
 */
public class HistoryDAO extends AbstractDAO implements IDAO<History, Integer>{

    @Override
    public List<History> getAll() throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    public List<History> getByEmpID(String empId) throws Exception {
        String sql = "select * from history where emp_id = ?";
        if (this.getCon() == null) {
            this.setCon(DAOFactory.creatConnection());
        }
        
        List<Map<String , Object>> result = this.getCon().queryList(sql,empId);
        List<History> his = new ArrayList<>();
        for (Map<String, Object> map : result) {
            History h = new History();
            h.setHistoryId(Integer.parseInt(map.get(History.field_history_id).toString()));
            h.setChangeBy(map.get(History.field_change_by).toString());
            h.setChangeOn((Date)map.get(History.field_changeon));
            h.setEmpId(map.get(History.field_emp_id).toString());
            h.setHistoryMsg(map.get(History.field_message).toString());
            h.setName(map.get(History.field_name).toString());
            his.add(h);
        }
        return his;
    }

    @Override
    public int updateSingle(History t, Integer id) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int deleteSingle(History t) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int insertSingle(History t) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public History getById(Integer id) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}
